import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { ProTable, ProColumns } from '@ant-design/pro-components';
import { queryPerformanceList } from '../service';
import { PerformanceRecordTableItem } from '../types.d';

const PerformanceRecordList = () => {
  const columns: ProColumns<PerformanceRecordTableItem>[] = [
    {
      title: 'id',
      hideInTable: true,
      hideInSearch: true,
      dataIndex: '_id',
    },
    {
      title: '日期',
      dataIndex: 'day',
      hideInForm: true,
      align: 'center',
      width: 100,
      valueType: 'date',
    },
    {
      title: '员工编号',
      dataIndex: 'jobNo',
      hideInForm: true,
      align: 'center',
      width: 80,
    },
    {
      title: '员工姓名',
      dataIndex: 'name',
      hideInForm: true,
      width: 80,
      align: 'center',
    },
    {
      title: '应录订单数',
      dataIndex: 'totalOrder',
      tooltip: '执勤时间段内驶入的订单数(次日更新)',
      hideInForm: true,
      hideInSearch: true,
      hideInTable: true,
      width: 80,
      align: 'center',
    },
    {
      title: '实录订单数',
      dataIndex: 'entryOrder',
      tooltip: '执勤时间段内录入车牌的订单数',
      hideInForm: true,
      hideInSearch: true,
      width: 80,
      align: 'center',
    },
    {
      title: '打印订单数',
      dataIndex: 'printOrder',
      tooltip: '执勤时间段内打印小票的数量',
      hideInForm: true,
      hideInSearch: true,
      width: 80,
      align: 'center',
    },
    {
      title: '追缴笔数',
      dataIndex: 'recoveryCounts',
      tooltip: '执勤时间段内追缴的次数',
      hideInForm: true,
      hideInSearch: true,
      width: 80,
      align: 'center',
    },
    {
      title: '追缴订单数',
      dataIndex: 'recoveryOrder',
      tooltip: '执勤时间段内追缴的欠费订单数量',
      hideInForm: true,
      hideInSearch: true,
      width: 80,
      align: 'center',
    },
    {
      title: '办理会员卡数',
      dataIndex: 'memberCard',
      tooltip: '执勤时间段内办理的会员卡数量',
      hideInForm: true,
      hideInSearch: true,
      width: 80,
      align: 'center',
    },
    {
      title: '实收订单金额',
      dataIndex: 'orderAmount',
      tooltip: '执勤时间段内收取的停车费用',
      hideInForm: true,
      hideInSearch: true,
      width: 80,
      align: 'center',
      valueType: 'money',
      renderText: (_, record) => (record.orderAmount || 0) / 100,
    },
    {
      title: '会员办理总金额',
      dataIndex: 'memberAmount',
      tooltip: '执勤时间段内办理会员卡收取的费用',
      hideInForm: true,
      hideInSearch: true,
      width: 80,
      align: 'center',
      valueType: 'money',
      renderText: (_, record) => (record.memberAmount || 0) / 100,
    },
    {
      title: '追缴总金额',
      dataIndex: 'recoveryAmount',
      tooltip: '执勤时间段内追缴欠费订单的总费用',
      hideInForm: true,
      hideInSearch: true,
      width: 80,
      align: 'center',
      valueType: 'money',
      renderText: (_, record) => (record.recoveryAmount || 0) / 100,
    },
  ];

  return (
    <PageHeaderWrapper
      header={{
        title: '',
        subTitle: '收费人员绩效管理列表',
        breadcrumb: {
          routes: [
            {
              path: '/',
              breadcrumbName: '首页',
            },
            {
              path: '/staff',
              breadcrumbName: '员工管理',
            },
            {
              path: '/staff/performance',
              breadcrumbName: '绩效列表',
            },
          ],
        },
      }}
    >
      <ProTable<PerformanceRecordTableItem>
        style={{ whiteSpace: 'nowrap' }}
        columns={columns}
        search={{ labelWidth: 'auto' }}
        rowKey="_id"
        columnEmptyText="暂无数据"
        debounceTime={300}
        request={async (param, sort) => {
          const res = await queryPerformanceList(param, sort);
          return res;
        }}
        dateFormatter="string"
        pagination={{
          showSizeChanger: true,
          showQuickJumper: true,
          defaultPageSize: 10,
          size: 'default',
        }}
      />
    </PageHeaderWrapper>
  );
};

export default PerformanceRecordList;
